#include <iostream>
#include "comm.hpp"
#include <sys/ipc.h>

using namespace std;

int main()
{
    int key = GetKey();
    int shmid = GetShm(key);

    char *s = (char *)shmat(shmid, NULL, 0);
    cout << "attach shm done" << endl;
    // sleep(5);

    int fd = open(filename, O_WRONLY);
    char c = 'a';

    for (; c <= 'z'; c++)
    {
        s[c - 'a'] = c;
        cout << "write " << c << " done" << endl;

        // 通知对方
        int code = 0;
        write(fd, &code, sizeof(code));
        sleep(3);
    }

    shmdt(s);
    cout << "detach shm done" << endl;

    close(fd);

    return 0;
}